package com.tencent.qf.team.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.tencent.qf.mybatis.pojo.PageRequest;
import com.tencent.qf.mybatis.pojo.PageResult;
import com.tencent.qf.team.dal.DmAppLeaderTaskJoinRecord;
import com.tencent.qf.team.dao.DmAppLeaderTaskJoinRecordDao;
import com.tencent.qf.team.dto.request.LeaderTaskJoinRecordLeaderCountRequest;
import com.tencent.qf.team.dto.request.LeaderTaskJoinRecordUnJoinLeaderCountRequest;
import com.tencent.qf.team.dto.response.LeaderTaskJoinRecordLeaderCountResponse;
import com.tencent.qf.team.service.LeaderTaskJoinRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LeaderTaskJoinRecordServiceImpl implements LeaderTaskJoinRecordService {
    @Autowired
    private DmAppLeaderTaskJoinRecordDao dmAppLeaderTaskJoinRecordDao;

    /**
     * 批量查找子任务下-可报名团长数
     *
     * @param request
     * @return
     */
    @Override
    public List<LeaderTaskJoinRecordLeaderCountResponse> listCanJoinTaskLeaderCount(LeaderTaskJoinRecordLeaderCountRequest request) {
        List<LeaderTaskJoinRecordLeaderCountResponse> list = dmAppLeaderTaskJoinRecordDao.listCanJoinTaskLeaderCount(request);
        return list;
    }

    /**
     * 未报名任务-团长列表(分页)
     *
     * @param request
     * @return
     */
    @Override
    public PageResult<DmAppLeaderTaskJoinRecord> listUnJoinTaskLeader(PageRequest<LeaderTaskJoinRecordUnJoinLeaderCountRequest> request) {
        PageHelper.startPage(request.getPageNo(), request.getPageSize());
        List<DmAppLeaderTaskJoinRecord> data = dmAppLeaderTaskJoinRecordDao.listUnJoinTaskLeader(request.getData());
        PageInfo<DmAppLeaderTaskJoinRecord> pageInfo = new PageInfo(data);
        return PageResult.build(pageInfo);
    }
}
